The present invention relates to object oriented computer applications, and more specifically, to reducing the amount of memory required by object oriented computer applications during runtime.
Java, an objected oriented programming language, is a robust language that provides mechanisms by which complex applications can easily be translated into different languages (e.g., French, English) (Java and all Java-based trademarks and logos are trademarks or registered trademarks of Oracle and/or its affiliates). Language translation is achieved in Java through a type of Java resource called a resource bundle, which is sometimes backed by class definitions or by Java property files. Class definitions and Java property files contain lists of key value pairs where the values are translated into different languages.
While the implementation of the resource bundle has allowed complex applications to be readily translated into many languages, this ease of translation has come with a significant cost to the application and its runtime characteristics. Namely, the amount of memory used by a translated application is far more than is actually needed in order to operate. As such, any large translated Java application requires considerable amounts of computer memory just to load all of the translated strings. Considerable amounts of memory are used because the Java framework handles translations by loading multiple sets of files for each resource bundle, with each file containing a different level of translation specificity (e.g., resource_English_England, resource_English, resource_default). In this example, where the values in the key value pairs are phrases, for any given translated phrase, there are three instances of the keys and the translated phrases are loaded and live in memory for effectively the life of the application once the bundle has been accessed. As the translation is multiplied across a number of bundles in a complex application, a very large amount of Java live heap bytes (or permanent memory for class definitions if the resource bundles were compiled to class files) is allocated just to hold the strings (e.g., the key value pairs).
In addition, in most cases, up to ninety percent of the strings are never used, so the memory is effectively wasted storing unused strings. This retention of strings is inefficient and bloats the memory requirements of Java applications. When products are stacked (i.e., products are built on top of other products), the problem multiplies. A typical stacked application may waste hundreds of megabytes of memory storing strings that are never accessed.